package org.example.general;

import java.io.*;
import java.nio.IntBuffer;
import java.util.Timer;

/**
 * 首先，我们需要乱序的生成2亿个数字，并将这些生成的数字写入到txt文件当中
 */
public class GeneralNumsToTxt {

    public static void main(String[] args) throws IOException {

        int i=200000000;

        File file = new File("num.txt");
        FileWriter bufferedWriter = new FileWriter(file);


        long startTime = System.currentTimeMillis();
        int num=10;
        while (i-->0){
            int temp = (int) (Math.random()*10000);
            bufferedWriter.write(temp);
            if(num-->0){
                System.out.print(temp+",");
            }
        }
        long endTime = System.currentTimeMillis();
        System.out.println("----------");
        System.out.println(endTime-startTime);
        bufferedWriter.close();
    }
}
